/**
 * @author Fayçal INAJJARANE
 */
package com.appspot.finajjarane.framework.generic;

import java.util.List;


public interface IGenericDao<T,PK> {


	/**
	 * Add an entity
	 * @param entity
	 * @return True if entity added, False otherwise
	 */
	public boolean add(final T entity) throws Exception;

	/**
	 * Update an entity
	 * @param entity
	 * @return the added entity, or null otherwise
	 */
	public T merge(final T entity) throws Exception;

	/**
	 * Remove an entity
	 * @param Key
	 * @return True if entity removed, False otherwise
	 */
	public boolean removeByKey(final PK key) throws Exception;

	/**
	 * Find an entity by its key
	 * @param key
	 * @return founded entity, null otherwise
	 */
	public T findByKey(final PK key) throws Exception;

	/**
	 * Get the full list of entities
	 * @return list of all founded entities
	 */
	public List<T> findAll() throws Exception;

	/**
	 * Get limited list of entities (usefull for pagination)
	 * @param page
	 * @param maxInPage
	 * @param lang
	 * @param orderByField
	 * @param orderByType
	 * @return list of all founded entities, but in limited number
	 */
	public List<T> getLimitedList(final int page, final int maxInPage, final String lang, final String orderByField, final String orderByType) throws Exception;

	/**
	 * Get total entries count for the current entity
	 * @param field
	 * @param lang
	 * @return int
	 */
	public int getEntriesCount(final String field, final String lang) throws Exception;

}
